﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ZedGraph;

namespace Biuro
{
    public partial class Wykresy : Form
    {
        public Wykresy()
        {
            InitializeComponent();
        }

        public DataTable daneKraj
        {
            set
            {
                wkKraj.AutoScroll = false;
                wkKraj.GraphPane.CurveList.Clear();
                wkKraj.Invalidate();
                GraphPane myPane = wkKraj.GraphPane;
                List<string> tmp = new List<string>();
                foreach (DataRow row in value.Rows)
                {
                    tmp.Add((string)row[0]);
                }
                myPane.Title.Text = "Wykres popularności krajów";
                myPane.XAxis.Title.Text = "Kraj";
                myPane.YAxis.Title.Text = "Ilość rezerwacji";
                DataSourcePointList dspl = new DataSourcePointList();
                dspl.DataSource = value;
                dspl.XDataMember = "kraj";
                dspl.YDataMember = "rezerwacje";
                dspl.ZDataMember = null;
                dspl.TagDataMember = "kraj";
                myPane.XAxis.Scale.TextLabels = tmp.ToArray();
                wkKraj.GraphPane.XAxis.Type = AxisType.Text;
                BarItem myCurve = myPane.AddBar("Kraj", dspl, Color.Blue);
                myPane.Chart.Fill = new Fill(Color.White,Color.FromArgb(255, 255, 166), 45.0F);
                wkKraj.IsShowPointValues = true;
                wkKraj.AxisChange();
                //myPane.YAxis.Scale.Max += myPane.YAxis.Scale.MajorStep; skaluje wykres
                BarItem.CreateBarLabels(myPane, false, "f0");
            }
        }
        public DataTable daneKurort
        {
            set
            {
                wkKurort.AutoScroll = false;
                wkKurort.GraphPane.CurveList.Clear();
                wkKurort.Invalidate();
                GraphPane myPane = wkKurort.GraphPane;
                List<string> tmp = new List<string>();
                foreach (DataRow row in value.Rows)
                {
                    tmp.Add((string)row[0]);
                }
                myPane.Title.Text = "Wykres popularności kurortów";
                myPane.XAxis.Title.Text = "Kurort";
                myPane.YAxis.Title.Text = "Ilość rezerwacji";
                DataSourcePointList dspl = new DataSourcePointList();
                dspl.DataSource = value;
                dspl.XDataMember = "kurort";
                dspl.YDataMember = "rezerwacje";
                dspl.ZDataMember = null;
                dspl.TagDataMember = "kurort";
                myPane.XAxis.Scale.TextLabels = tmp.ToArray();
                wkKurort.GraphPane.XAxis.Type = AxisType.Text;
                BarItem myCurve = myPane.AddBar("Kurort", dspl, Color.Blue);
                myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 166), 45.0F);
                wkKurort.IsShowPointValues = true;
                wkKurort.AxisChange();
                BarItem.CreateBarLabels(myPane, false, "f0");
            }
        }
        private void Wykresy_Load(object sender, EventArgs e)
        {
        }

    }
}
